package com.hst.capacity.facade.rest;

import com.hst.capacity.application.biz.StatisticsBiz;
import com.hst.capacity.application.biz.TokenBiz;
import com.hst.capacity.domain.model.entity.auth.TokenEntity;
import com.hst.capacity.domain.model.request.statistics.StatisticsParam;
import com.hst.capacity.domain.model.response.DefaultVO;
import com.hst.capacity.domain.service.TokenService;
import com.hst.capacity.infra.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

import static com.hst.capacity.domain.model.response.DefaultVO.success;

/**
 *  统计模块Controller
 *
 * */
@RequestMapping("/statistics")
@RestController
public class StatisticsController {

    @Autowired
    private StatisticsBiz statisticsBiz;

    @Autowired
    TokenBiz tokenBiz;

    /**
     * 日统计一览
     * @param
     * @return
     */
    @PostMapping("/list/daily")
    private DefaultVO getStatisticsDailyList(@RequestBody @Valid StatisticsParam param, HttpServletRequest request){
        param.setIdUser(tokenBiz.findIdUser(request));
        return success(statisticsBiz.findStatisticsDailyLst(param));
    }

    /**
     * 指定范围统计数据表示
     * @param
     * @return
     */
    @PostMapping("/one")
    private DefaultVO getStatisticsDataOne(@RequestBody @Valid StatisticsParam param, HttpServletRequest request){
        param.setIdUser(tokenBiz.findIdUser(request));
        return success(statisticsBiz.getStatisticsDataOne(param));
    }

}
